************************************************************************************************************************************************************
* This do-file is part of the replication package for "Committee Decision-Making under the Threat of Leaks" by Fehrler and Hahn (JOP)
* It contains all analyses in the paper
* The analyses were conducted using Stata 16.1 and made use of the easstab command from package st0085_2 from http://www.stata-journal.com/software/sj14-2
* The path needs to be set in line 8
************************************************************************************************************************************************************

//global path "[Insert your replication-files folder path here]"
global path "C:\Users\tempora\Dropbox\CommitteeLeaks\Experiment\stata\replication-files"
cd $path
use alldata-rec.dta, clear

global graphsetting "graphregion(color(white) lwidth(large)) scheme(s1mono)"

//random seed for bootstrap (723677607) was taken from random.org 
//all following analyses use clustered ses on the subject level
//change cluster(sid) to cluster(mid) to cluster on the matching-group level

************************************************************************************************************************************************************
//Communication
************************************************************************************************************************************************************

//Table 2
*own blue signal
reg message tr_* if  ball_color==color_type& scenario==1, nocon cluster(sid)
reg message tr_* if  ball_color==color_type& scenario==2, nocon cluster(sid)
*other blue signal
reg message tr_* if  ball_color!=color_type& ball_color!=5 & color_type!=3 & ball_color!=0 & scenario==1, nocon cluster(sid)
reg message tr_* if  ball_color!=color_type& ball_color!=5 & color_type!=3 & ball_color!=0 & scenario==2, nocon cluster(sid)
*any blue signal
reg message tr_* if  ball_color!=5 & color_type==3 & ball_color!=0  & scenario==1, nocon cluster(sid)
reg message tr_* if  ball_color!=5 & color_type==3 & ball_color!=0  & scenario==2, nocon cluster(sid)
*red signal
reg message tr_* if  ball_color==5   & scenario==1, nocon cluster(sid)
reg message tr_* if  ball_color==5   & scenario==2, nocon cluster(sid)


reg message tr_* if  ball_color!=0, nocon  cluster(sid) 
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

reg message tr_* if  ball_color!=0 & scenario==1, nocon  cluster(sid) 
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

reg message tr_* if  ball_color!=0 & scenario==2, nocon  cluster(sid) 
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

//Best Responses Comparison

reg eq_communication tr_*, nocon  cluster(sid) 
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

reg eq_communication tr_*, nocon  cluster(mid) 
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]


//Behavior Over Time (online Appendix)
* over time
reg message if  ball_color==color_type& tr_transparency & scenround<6, cluster(sid)
reg message if  ball_color==color_type& tr_transparency & scenround>5, cluster(sid)

reg message if  ball_color!=5 & color_type==3 & ball_color!=0 & tr_transparency & scenround<6, cluster(sid)
reg message if  ball_color!=5 & color_type==3 & ball_color!=0 & tr_transparency & scenround>5, cluster(sid)

reg message if  ball_color==color_type& tr_leaks & scenround<6, cluster(sid)
reg message if  ball_color==color_type& tr_leaks & scenround>5, cluster(sid)

reg message if  ball_color!=5 & color_type==3 & ball_color!=0 & tr_leaks & scenround<6, cluster(sid)
reg message if  ball_color!=5 & color_type==3 & ball_color!=0 & tr_leaks & scenround>5, cluster(sid)



************************************************************************************************************************************************************
//Voting in the Avisory Committee and Leaks
************************************************************************************************************************************************************

//Communication of red (bad) signal
tab comm_state treatment if state==5,col	

//Table 3
//state publicly known
*SOTW own blue
reg recom_vote tr_* if scenario==1 & comm_state==1 & state==color_type, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==1 & state==color_type, nocon cluster(sid)
*SOTW other blue
reg recom_vote tr_* if scenario==1 & comm_state==1 & state!=color_type& state!=5 & color_type!=3 , nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==1 & state!=color_type& state!=5 & color_type!=3, nocon cluster(sid)
*SOTW any blue
reg recom_vote tr_* if scenario==1 & comm_state==1 & state!=5 & color_type==3 , nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==1 & state!=5 & color_type==3, nocon cluster(sid)
*SOTW red
reg recom_vote tr_* if scenario==1 & comm_state==1 & state==5, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==1 & state==5, nocon cluster(sid)

//state not publicly known
*SOTW own blue
reg recom_vote tr_* if scenario==1 & comm_state==0 & ball_color==color_type, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==0 & ball_color==color_type, nocon cluster(sid)
*SOTW other blue
reg recom_vote tr_* if scenario==1 & comm_state==0 & ball_color!=color_type& ball_color!=5 & color_type!=3, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==0 & ball_color!=color_type& ball_color!=5 & color_type!=3, nocon cluster(sid)
*SOTW any blue
reg recom_vote tr_* if scenario==1 & comm_state==0 & ball_color!=5 & color_type==3, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==0 & ball_color!=5 & color_type==3, nocon cluster(sid)
*SOTW red
reg recom_vote tr_* if scenario==1 & comm_state==0 & ball_color==5, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==0 & ball_color==5, nocon cluster(sid)
*no signal
reg recom_vote tr_* if scenario==1 & comm_state==0 & ball_color==0, nocon cluster(sid)
reg recom_vote tr_* if scenario==2 & comm_state==0 & ball_color==0, nocon cluster(sid)

//Leaks: leaks are quite frequent but subjects often still do not leak when they should

reg any_leak red_state blue_state, nocon cluster(sid)
reg any_leak if advisor==1 & recom_committee==1 , cluster(sid)
reg any_leak  if advisor==1 & recom_committee==0 , cluster(sid)

tab any_leak scenario if red_state==0 & tr_leaks, col 
tab leak if advisor==1 & recom_committee==1 & (((comm_state==1 & light_state) | light_ball==1) & dark_type | ((comm_state==1 & dark_state) | dark_ball==1) & light_type) & tr_leaks
tab leak neutral_type if state!=5, col
sum leak any_leak if scenario==1

//Further Analysis
*over time (online Appendix)
tab leak if advisor==1 & recom_committee==1 & (((comm_state==1 & light_state) | light_ball==1) & dark_type | ((comm_state==1 & dark_state) | dark_ball==1) & light_type) /*
*/ & tr_leaks & scenround<6

tab leak if advisor==1 & recom_committee==1 & (((comm_state==1 & light_state) | light_ball==1) & dark_type | ((comm_state==1 & dark_state) | dark_ball==1) & light_type) /*
*/ & tr_leaks & scenround>5


************************************************************************************************************************************************************
//Behavior of Decision-Makers
************************************************************************************************************************************************************

tab state_known treatment,col	//state often known (except for secrecy of course)
tab vote_committee recom_committee, col

//Table 4
*HQ
reg vote_committee recom_committee if scenario==1 & tr_secrecy & state_known==0, nocon cluster(sid)
reg vote_committee recom_committee if scenario==1 & tr_transparency & state_known==0, nocon cluster(sid)
reg vote_committee recom_committee if scenario==1 & tr_leaks & state_known==0, nocon cluster(sid)
*LQ
reg vote_committee recom_committee if scenario==2 & tr_secrecy & state_known==0, nocon cluster(sid)
reg vote_committee recom_committee if scenario==2 & tr_transparency & state_known==0, nocon cluster(sid)
reg vote_committee recom_committee if scenario==2 & tr_leaks & state_known==0, nocon cluster(sid)


reg vote_committee if bad_state_known==1, cluster(sid)
reg vote_committee if good_state_known==1, cluster(sid)

//Further Analysis
//Table 7
reg vote_committee recom_same recom_other recom_neutral recom_committee if state_known==0 & tr_transparency, cluster(sid)
esttab, tex b(%9.3f) se(%9.3f) scalars(N_clust) sfmt(%9.0f) r2(%9.2f) starl(* 0.10 ** 0.05 *** 0.01) ///
title() mti("") compress nogaps nonum replace wide

reg vote_committee recom_same recom_other recom_neutral if state_known==0 &  recom_committee==0 & tr_transparency, cluster(sid)
reg vote_committee recom_same recom_other recom_neutral if state_known==0 &  recom_committee==1 & tr_transparency, cluster(sid)
reg vote_committee recom_same recom_other recom_neutral if state_known==0 & tr_transparency, cluster(sid)

tab deci_committee any_leak, col
tab deci_committee comm_state if tr_leaks & red_state==0 & ball_color==state & (ball_color==color_type| color_type==3) & scenario==1, col
tab deci_committee comm_state if tr_leaks & red_state==0 & ball_color==state & (ball_color==color_type| color_type==3) & scenario==2, col

* over time
reg vote_committee recom_same recom_other recom_neutral if state_known==0 & tr_transparency & scenround<6 , cluster(sid)
reg vote_committee recom_same recom_other recom_neutral if state_known==0 & tr_transparency & scenround>5 , cluster(sid)


************************************************************************************************************************************************************
//Aggregate decisions and welfare; code for figures comes at the end of the do-file
************************************************************************************************************************************************************
reg deci_committee if comm_state==1 &  tr_leaks, cluster(sid)
reg deci_committee if comm_state==1 &  tr_transparency, cluster(sid)
reg deci_committee if comm_state==1 &  tr_secrecy, cluster(sid)

//Table 5
*HQ
reg deci_committee tr_* if color_type==3 & scenario==1, nocons cluster(sid)
*LQ
reg deci_committee tr_* if color_type==3 & scenario==2, nocons cluster(sid)


reg deci_committee tr_* if color_type==3 & scenario==1, nocons cluster(sid)
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

reg deci_committee tr_* if color_type==3 & scenario==2, nocons cluster(sid)
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]


reg deci_committee tr_* if color_type==3 & scenario==1 & blue_state, nocons cluster(sid)
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

reg deci_committee tr_* if color_type==3 & scenario==2 & blue_state, nocons cluster(sid)
test _b[tr_secrecy]=_b[tr_transparency]
test _b[tr_secrecy]=_b[tr_leaks]
test _b[tr_transparency]=_b[tr_leaks]

************************************************************************************************************************************************************
//Welfare Groups 
************************************************************************************************************************************************************

//Table 6
*HQ
reg deci_committee red_s_* blue_s_* if color_type==3 & scenario==1 , nocons cluster(sid)
lincom 0.8*_b[blue_s_sec]*10 - 0.2*_b[red_s_sec]*54			//welfare secrecy
lincom 0.8*_b[blue_s_transp]*10 - 0.2*_b[red_s_transp]*54	//welfare transparency
lincom 0.8*_b[blue_s_leaks]*10 - 0.2*_b[red_s_leaks]*54		//welfare leaks
*LQ
reg deci_committee red_s_* blue_s_* if color_type==3 & scenario==2 , nocons cluster(sid)
lincom 0.8*_b[blue_s_sec]*2 - 0.2*_b[red_s_sec]*54			//welfare secrecy
lincom 0.8*_b[blue_s_transp]*2 - 0.2*_b[red_s_transp]*54	//welfare transparency
lincom 0.8*_b[blue_s_leaks]*2 - 0.2*_b[red_s_leaks]*54		//welfare leaks


display (0.8*_b[blue_s_leaks]*10 - 0.2*_b[red_s_leaks]*54 - 0.45*3*1 - 0.1722*1 ) //with costs of leaks scenario 1
display (0.8*_b[blue_s_leaks]*2 - 0.2*_b[red_s_leaks]*54 - 0.4944*3*1 - 0.2031*1) //with costs of leaks scenario 2


reg deci_committee red_s_* blue_s_* if color_type==3 & scenario==1, nocon cluster(sid) 

test 0.8*blue_s_sec*10 - 0.2*red_s_sec*54 = 0.8*blue_s_leaks*10 - 0.2*red_s_leaks*54    
test 0.8*blue_s_sec*10 - 0.2*red_s_sec*54 = 0.8*blue_s_transp*10 - 0.2*red_s_transp*54  
test 0.8*blue_s_leaks*10 - 0.2*red_s_leaks*54 = 0.8*blue_s_transp*10 - 0.2*red_s_transp*54  
test 0.8*blue_s_sec*10 - 0.2*red_s_sec*54 = 0.8*blue_s_leaks*10 - 0.2*red_s_leaks*54 = 0.8*blue_s_transp*10 - 0.2*red_s_transp*54  


reg deci_committee red_s_* blue_s_* if color_type==3 & scenario==2, nocon cluster(sid) 

test 0.8*blue_s_sec*2 - 0.2*red_s_sec*54 = 0.8*blue_s_leaks*2 - 0.2*red_s_leaks*54    
test 0.8*blue_s_sec*2 - 0.2*red_s_sec*54 = 0.8*blue_s_transp*2 - 0.2*red_s_transp*54  
test 0.8*blue_s_leaks*2 - 0.2*red_s_leaks*54 = 0.8*blue_s_transp*2 - 0.2*red_s_transp*54 
test 0.8*blue_s_sec*2 - 0.2*red_s_sec*54 = 0.8*blue_s_leaks*2 - 0.2*red_s_leaks*54 = 0.8*blue_s_transp*2 - 0.2*red_s_transp*54  


*inequality
preserve
collapse sdpoints treat mid sid gid scenario, by (gpid)
by treat, sort: reg sdpoints if  scenario==1
by treat, sort:  reg sdpoints if  scenario==2
reg sdpoints i.treat if scenario==1
reg sdpoints i.treat if scenario==2
restore


************************************************************************************************************************************************************
//Figures 
************************************************************************************************************************************************************
//Figure 1 (a)

bootstrap , rep(10000) cluster(sid) seed(723677607) nodots: reg deci_committee secr_* tran_* leak_* if red_state==0 , nocons
estat bootstrap , p

preserve
statsby, by(treatment scenario): ci prop deci_committee if red_state==0
drop se

replace lb= .708597 in 1		//these values come from bootstrapped CIs above
replace ub= .7788687 in 1
replace lb= .4278845 in 2
replace ub= .5014265		 in 2
replace lb= .1770903 in 3     
replace ub= .2362486 in 3
replace lb= .0866551 in 4  
replace ub= .1458025 in 4
replace lb= .3232253  in 5     
replace ub= .3997082 in 5
replace lb= .2233466  in 6      
replace ub= .2912503 in 6 

ren proportion deci_committee
ren ub hideci_committee
ren lb lowdeci_committee

gen diamond=1 
replace diamond=.75 in 2
replace diamond=.5 in 3
replace diamond=.25 in 4
replace diamond=.5 in 5
replace diamond=.25 in 6

gen diamond2=.
replace diamond2=1 in 2

generate pos = treatment-1    if scenario == 1 
replace  pos = treatment +2  if scenario == 2
sort pos

twoway (bar deci_committee pos if treatment==1,  yscale(range(0 1)) ylabel(0(.2)1)) ///
       (bar deci_committee pos if treatment==2,  yscale(range(0 1)) ylabel(0(.2)1)) ///
	   (bar deci_committee pos if treatment==3,  yscale(range(0 1)) ylabel(0(.2)1)) ///
	   (rcap hideci_committee lowdeci_committee pos, color(black)) ///
	   	   (scatter diamond pos, color(black) msymbol(circle)) ///
		   (scatter diamond2 pos, color(black) msymbol(circle)), ///
	   legend(row(1) order(1 "Secrecy" 2 "Transparency" 3 "Leaks") ) ///
       xlabel( 1 "Scenario HQ" 4 "Scenario LQ", noticks) ///
       ytitle("Share of Implementations") xtitle("") title("(a)") $graphsetting
restore	  

//Figure 1 (b)

bootstrap , rep(10000) cluster(sid) seed(723677607) nodots: reg deci_committee secr_* tran_* leak_* if red_state==1 , nocons
estat bootstrap , p


preserve
statsby, by(treatment scenario): ci prop deci_committee if red_state==1

drop se

replace lb= .0876035 in 1       	//these values come from bootstrapped CIs above
replace ub= .1822034 in 1
replace lb= .005988 in 2       
replace ub= .0535714  in 2
replace lb= .0073529 in 3         
replace ub= .0616861 in 3
replace lb= .0183318 in 4        
replace ub= .0643174  in 4
replace lb= .0653164 in 5        
replace ub= .1524237  in 5
replace lb= .0067114 in 6         
replace ub= .0620422 in 6 

ren proportion deci_committee
ren ub hideci_committee
ren lb lowdeci_committee

gen diamond=0.125 
replace diamond=0 in 2
replace diamond=0 in 3
replace diamond=0 in 4
replace diamond=0 in 5
replace diamond=0 in 6

gen diamond2=.
replace diamond2=0.125 in 2

generate pos = treatment-1    if scenario == 1 
replace  pos = treatment +2  if scenario == 2
sort pos

twoway (bar deci_committee pos if treatment==1,  yscale(range(0 0.2)) ylabel(0(.2)1)) ///
       (bar deci_committee pos if treatment==2,  yscale(range(0 0.2)) ylabel(0(.2)1)) ///
	   (bar deci_committee pos if treatment==3,  yscale(range(0 0.2)) ylabel(0(.2)1)) ///
	   (rcap hideci_committee lowdeci_committee pos, color(black)) ///
	   (scatter diamond pos, color(black) msymbol(circle)) ///
	   (scatter diamond2 pos, color(black) msymbol(circle)), ///
	   legend(row(1) order(1 "Secrecy" 2 "Transparency" 3 "Leaks") ) ///
       xlabel( 1 "Scenario HQ" 4 "Scenario LQ", noticks)  yscale(range(0 1)) ///
       ytitle("Share of Implementations") xtitle("") title("(b)") $graphsetting

restore

//Further Analysis (over time) 

//Figure 1 (online Appendix I)
* first half

bootstrap , rep(10000) cluster(sid) seed(723677607) nodots: reg deci_committee secr_* tran_* leak_* if red_state==0 & scenround<6, nocons
estat bootstrap , p

preserve
statsby, by(treatment scenario): ci prop deci_committee if red_state==0 & scenround<6
drop se

replace lb= .7004376 in 1		//these values come from bootstrapped CIs above
replace ub= .7965189 in 1
replace lb= .445415 in 2
replace ub= .5543016		 in 2
replace lb= .1731109 in 3     
replace ub= .2638889 in 3
replace lb= .0949367 in 4  
replace ub= .1746894 in 4
replace lb= .265912  in 5     
replace ub= .3618216 in 5
replace lb= .2339833  in 6      
replace ub= .3376623 in 6 

ren proportion deci_committee
ren ub hideci_committee
ren lb lowdeci_committee

gen diamond=1 
replace diamond=.75 in 2
replace diamond=.5 in 3
replace diamond=.25 in 4
replace diamond=.5 in 5
replace diamond=.25 in 6

gen diamond2=.
replace diamond2=1 in 2

generate pos = treatment-1    if scenario == 1 
replace  pos = treatment +2  if scenario == 2
sort pos

twoway (bar deci_committee pos if treatment==1,  yscale(range(0 1)) ylabel(0(.2)1)) ///
       (bar deci_committee pos if treatment==2,  yscale(range(0 1)) ylabel(0(.2)1)) ///
	   (bar deci_committee pos if treatment==3,  yscale(range(0 1)) ylabel(0(.2)1)) ///
	   (rcap hideci_committee lowdeci_committee pos, color(black)) ///
	   	   (scatter diamond pos, color(black) msymbol(circle)) ///
		   (scatter diamond2 pos, color(black) msymbol(circle)), ///
	   legend(row(1) order(1 "Secrecy" 2 "Transparency" 3 "Leaks") ) ///
       xlabel( 1 "Scenario HQ" 4 "Scenario LQ", noticks) ///
       ytitle("Share of Implementations") xtitle("") title("Rounds 1-5") $graphsetting
restore	 

*second half

bootstrap , rep(100) cluster(sid) seed(723677607) nodots: reg deci_committee secr_* tran_* leak_* if red_state==0 & scenround>5, nocons
estat bootstrap , p  	

preserve
statsby, by(treatment scenario): ci prop deci_committee if red_state==0 & scenround>5
drop se

replace lb= .6732673 in 1		//these values come from bootstrapped CIs above
replace ub= .7660819 in 1
replace lb= .372549 in 2
replace ub= .4880546		 in 2
replace lb= .1633166 in 3     
replace ub= .2326139 in 3
replace lb= .0706522 in 4  
replace ub= .1339869 in 4
replace lb= .3553009  in 5     
replace ub= .4587459 in 5
replace lb= .1689751  in 6      
replace ub= .2869318 in 6 

ren proportion deci_committee
ren ub hideci_committee
ren lb lowdeci_committee

gen diamond=1 
replace diamond=.75 in 2
replace diamond=.5 in 3
replace diamond=.25 in 4
replace diamond=.5 in 5
replace diamond=.25 in 6

gen diamond2=.
replace diamond2=1 in 2

generate pos = treatment-1    if scenario == 1 
replace  pos = treatment +2  if scenario == 2
sort pos

twoway (bar deci_committee pos if treatment==1,  yscale(range(0 1)) ylabel(0(.2)1)) ///
       (bar deci_committee pos if treatment==2,  yscale(range(0 1)) ylabel(0(.2)1)) ///
	   (bar deci_committee pos if treatment==3,  yscale(range(0 1)) ylabel(0(.2)1)) ///
	   (rcap hideci_committee lowdeci_committee pos, color(black)) ///
	   	   (scatter diamond pos, color(black) msymbol(circle)) ///
		   (scatter diamond2 pos, color(black) msymbol(circle)), ///
	   legend(row(1) order(1 "Secrecy" 2 "Transparency" 3 "Leaks") ) ///
       xlabel( 1 "Scenario HQ" 4 "Scenario LQ", noticks) ///
       ytitle("Share of Implementations") xtitle("") title("Rounds 6-10") $graphsetting
restore	 



************************************************************************************************************************************************************
exit


